<template>
  <div class="business-list" ref="box">
    <div class="myvan-image2">
      <div class="business-title" v-for="item in list" :key="item.id">
        <div>{{item[0]}}</div>
        <div class="business-more">
          <span>查看更多>></span>
        </div>

        <div class="business-list2">
          <div class="list-box" v-for="item2 in item[1]" :key="item2.id">
            <van-image
              :src="item2.imgSrc"
              rel="external nofollow"
              class="business-img"
            />
            <div class="business-brand">
              <h5>{{item2.name}}</h5>
              <span>{{item2.engineModel}}</span>
            </div>
            <div class="business-price">
              <span>{{item2.dailyPrice}}</span>
              <span>
                <van-icon name="arrow" />
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { selectCompanyCar } from "../../../api";

export default {
  name: 'businessList',
  props: {
    listData: Array
  },
  data() {
    return {
      businessList: [], // 用来存每一个公司和对应的车辆
      list: []
    }
  },
  created(){
  },
  mounted() {
  },
  methods: {
    getBusiness() {
      this.listData.forEach(item => {
        selectCompanyCar(item.company).then(res3 => {
          this.businessList = [item.company, res3.data.data];
          this.list.push(this.businessList);
        })
      });
    }
  }
}
</script>
<style lang="scss" scoped>
// 商家
  .myvan-image2 {
    border-radius: 10px;
    padding: 10px;
    box-sizing: border-box;
  }
  .business-list {
    width: 100%;
    padding-bottom: 100px;
    // 标题
    .business-title {
      width: 100%;
      height: 100%;
      display: flex;
      flex-flow: row wrap;
      justify-content: space-between;
      margin-top: 10px;
      background-color: #fff;
      .title-box {
        display: flex;
        justify-content: space-between;
        .business-flag {
          width: 60px;
          height: $height/2;
          line-height: $height/2;
          text-align: center;
          background-color: $color;
          border-radius: 4px;
          color: #fff;
          font-size: 8px;
          margin-left: 8px;
        }
      }
      .business-more {
        font-size: 8px;
        margin-right: 10px;
        color: #aaa;
      }
    }
    // 内容
    .business-list2 {
      width: 100%;
      display: flex;
      justify-content: flex-start;
      flex-flow: row nowrap;
      overflow-x: scroll;
      .list-box {
        width: 33%;
        border: 1px solid rgb(247, 247, 247);
        padding: 6px;
        box-sizing: border-box;
        flex-shrink: 0;
        .van-image {
          width: 100%;
        }
        // 品牌
        .business-brand {
          display: flex;
          justify-content: flex-start;
          padding: 0 6px;
          box-sizing: border-box;
          margin-top: 10px;
          h5, span {
            font-size: 12px;
          }
          span {
            margin-left: 6px;
            line-height: 16px;
            font-weight: 700;
          }
        }
        // 价格
        .business-price {
          display: flex;
          justify-content: space-between;
          span {
            &:nth-of-type(1) {
              color: #f31616;
              font-size: 8px;
              line-height: 30px;
              &::before {
                content: '￥';
                font-size: 8px;
              }
              &::after {
                content: '/天';
                font-size: 8px;
                color: #333;
              }
            }
            &:nth-of-type(2) {
              display: inline-block;
              transform: scale(0.5);
              width: 20px;
              height: 20px;
              border-radius: 50%;
              font-size: 20px;
              text-align: center;
              padding: 4px;
              background-color: #f31616;
              color: #fff;
            }
          }
        }
      }
    }
  }
  /* 隐藏滚动条 */
  ::-webkit-scrollbar {
    display: none;
  }
</style>